package str

import "strconv"

func originalDigits(s string) string {
	c := map[rune]int{}
	for _, ch := range s {
		c[ch]++
	}

	cnt := [10]int{}
	cnt[0] = c['z']
	cnt[6] = c['x']
	cnt[2] = c['w']
	cnt[4] = c['u']
	cnt[8] = c['g']

	cnt[5] = c['f'] - cnt[4]
	cnt[7] = c['v'] - cnt[5]
	cnt[3] = c['h'] - cnt[8]

	cnt[1] = c['o'] - cnt[0] - cnt[2] - cnt[4]

	cnt[9] = c['i'] - cnt[5] - cnt[6] - cnt[8]

	res := ""

	for i, v := range cnt {
		for j := 0; j < v; j++ {
			res += strconv.Itoa(i)
		}
	}

	return res

}
